/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package za.co.pas.business.data;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.OneToOne;

/**
 *
 * @author alabuschagne
 */
@Entity
public class BusinessCurrency extends GenericData implements Serializable
{
    private static final long serialVersionUID = 1L;
    private String code;
    private String symbol;
    private Country country;

    public BusinessCurrency()
    {
        super();
    }

    public BusinessCurrency(String code, String symbol, String name, Country country)
    {
        super();
        this.code = code;
        this.symbol = symbol;
        this.name = name;
        this.country = country;
    }


    @Override
    public int hashCode()
    {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BusinessCurrency))
        {
            return false;
        }
        BusinessCurrency other = (BusinessCurrency) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        if(code != null)
        {
            sb.append(code);
        }
        else
        {
            sb.append("No currency code");
        }
        sb.append(" | ");
        if(name != null)
        {
            sb.append(name);
        }
        else
        {
            sb.append("No currency name");
        }
        sb.append(" | ");
        if(symbol != null)
        {
            sb.append(symbol);
        }
        else
        {
            sb.append("No currency symbol");
        }
        sb.append(" | ");
        if(country != null)
        {
            sb.append(country.getCode());
            sb.append(",");
            sb.append(country.getName());
        }
        else
        {
            sb.append("No country");
        }
        return sb.toString();
    }

    /**
     * @return the code
     */
    public String getCode()
    {
        return code;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code)
    {
        this.code = code;
    }

    /**
     * @return the symbol
     */
    public String getSymbol()
    {
        return symbol;
    }

    /**
     * @param symbol the symbol to set
     */
    public void setSymbol(String symbol)
    {
        this.symbol = symbol;
    }

    /**
     * @return the country
     */
    @OneToOne
    public Country getCountry()
    {
        return country;
    }

    /**
     * @param country the country to set
     */
    public void setCountry(Country country)
    {
        this.country = country;
    }

}
